package com.cdks.wuxiu.common.model.param;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@ApiModel(description = "分页参数")
@Data
public class PageParam {
    @ApiModelProperty(value = "查询页码", example = "1", position = -2)
    private Integer pageIndex = 1;
    @ApiModelProperty(value = "每页数量", example = "20", position = -2)
    private Integer pageSize = 20;
    @ApiModelProperty(value = "排序字段")
    private String orderBy;
    @ApiModelProperty(value = "排序方式")
    private Boolean orderAsc;

    public String getSort() {
        if (orderBy != null && orderAsc != null) {
            if (orderAsc) {
                return orderBy + " " + "ASC";
            } else {
                return orderBy + " " + "DESC";
            }
        }
        return null;
    }
}
